<div class="ui-portlet">
    <ol class="breadcrumb">
      <li class="active">公司信息</li>
    </ol>
</div>           
<hr>

<a href="/admin/companies/batchaddmember/{{$id}}" class="btn btn-primary">增加人员</a>

{{if $datainfo['Company']['status'] == 1 }}
        <p class="alert alert-success">审核已通过。</p>
{{elseif $datainfo['Company']['status'] == 3 }}
        <p class="alert alert-warning">审核未通过。 {{$datainfo['Company']['audit_msg']}}</p>
{{elseif $datainfo['Company']['status'] == 0  }}
        <p class="alert alert-info">未提交审核。</p>
{{/if}}

<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
  <li role="presentation" class="active"><a href="#CompanyInfo" role="tab" data-toggle="tab">公司信息</a></li>
  <li role="presentation"><a href="#CompanyMember" role="tab" data-toggle="tab">公司成员</a></li>
  <li role="presentation"><a href="#MoreInfo" role="tab" data-toggle="tab">更多信息</a></li>
</ul>

<div class="tab-content">
  <div role="tabpanel" class="tab-pane active" id="CompanyInfo">
    <div class="clearfix">
        <label class="col-sm-2" for="CompanyName">公司名称</label>
        <div class="col-sm-9 controls">
            {{$datainfo['Company']['name']}}
        </div>
    </div>
    
    {{if $datainfo['Company']['groupid']}}
    <div class="clearfix">
        <label class="col-sm-2" for="CompanyAddress">环信群组编号</label>
        <div class="col-sm-9 controls" style="color:red;">
            {{$datainfo['Company']['groupid']}}
        </div>
    </div>
    {{elseif Configure::read('Easemob.open') == 1}}
    <div class="clearfix">
        <label class="col-sm-2" for="CompanyAddress">环信群组未添加</label>
        <div class="col-sm-9 controls" style="color:red;">
            <form class="form" action="/admin/companies/addEasemodGroup/{{$datainfo['Company']['id']}}">
            <button onclick="ajaxAction(this.form);" class="btn btn-primary" >生成环信群组</button>
            </form>
        </div>
    </div>
    {{/if}}
    
    <div class="clearfix">
        <label class="col-sm-2" for="CompanyAddress">公司地址</label>
        <div class="col-sm-9 controls">
            {{$datainfo['Company']['address']}}
        </div>
    </div>
    <div class="clearfix">
        <label class="col-sm-2" for="CompanyWebsite">公司网址</label>
        <div class="col-sm-9 controls">
            {{$datainfo['Company']['website']}}
        </div>
    </div>
    <hr/>
    <div class="clearfix">
        <label class="col-sm-2" >营业执照号</label>
        <div class="col-sm-9 controls">
            {{$datainfo['Company']['zhizhao']}}
        </div>
    </div>
    <div class="clearfix">
        <label class="col-sm-2" >营业执照附件</label>
        <div class="col-sm-9 controls">
        {{if $datainfo['Company']['zhizhaofile']}}
            <a href="{{$datainfo['Company']['zhizhaofile']}}" target="_blank">
                <img src="{{$datainfo['Company']['zhizhaofile']}}" style="width:300px;">
            </a>
        {{else}}
            <a href="/companies/edit/{{$datainfo['Company']['id']}}"><span style="color:red;">未上传</span></a>
        {{/if}}
        </div>
    </div>
    <div class="clearfix">
        <label class="col-sm-2">注册地址</label>
        <div class="col-sm-9 controls">
            {{$datainfo['Company']['zcdz']}}
        </div>
    </div>
    <div class="clearfix">
        <label class="col-sm-2">经营范围</label>
        <div class="col-sm-9 controls">
            {{$datainfo['Company']['jyfw']}}
        </div>
    </div>
    <div class="clearfix">
        <label class="col-sm-2" >负责人</label>
        <div class="col-sm-9 controls">
            {{$datainfo['Company']['corporation']}}
        </div>
    </div>
    <div class="clearfix">
        <label class="col-sm-2" >负责人身份证</label>
        <div class="col-sm-9 controls">
            {{$datainfo['Company']['corporation_identity']}}
        </div>
    </div>
    <div class="clearfix">
        <label class="col-sm-2" >负责人手持身份证照片</label>
        <div class="col-sm-9 controls">
        {{if $datainfo['Company']['corporation_files']}}
            <a href="{{$datainfo['Company']['corporation_files']}}" target="_blank">
                <img src="{{$datainfo['Company']['corporation_files']}}" style="width:300px;">
            </a>
        {{else}}
            <a href="/companies/edit/{{$datainfo['Company']['id']}}"><span style="color:red;">未上传</span></a>
        {{/if}}
        </div>
    </div>
    
    <hr/>

    <div class="clearfix">
        <label class="col-sm-2" for="CompanyMobilePhone">联系手机</label>
        <div class="col-sm-9 controls">
            {{$datainfo['Company']['mobile_phone']}}
        </div>
    </div>
    <div class="clearfix">
        <label class="col-sm-2" for="CompanyMobilePhone">联系微信</label>
        <div class="col-sm-9 controls">
            {{$datainfo['Company']['wechat']}}
        </div>
    </div>
    <div class="clearfix">
        <label class="col-sm-2" for="CompanyMobilePhone">联系QQ</label>
        <div class="col-sm-9 controls">
            {{$datainfo['Company']['qq']}}
        </div>
    </div>
    <div class="clearfix">
        <label class="col-sm-2" for="CompanyTelephone">公司电话</label>
        <div class="col-sm-9 controls">
            {{$datainfo['Company']['phone']}}
        </div>
    </div>
    <div class="clearfix">
        <label class="col-sm-2" for="CompanyEmail">公司邮箱</label>
        <div class="col-sm-9 controls">
            {{$datainfo['Company']['email']}}
        </div>
    </div>
    <hr/>
    <div class="clearfix">
        <label class="col-sm-2" for="CompanyName">更多描述</label>
        <div class="col-sm-9">
            {{$datainfo['Company']['summary']}}
        </div>
    </div>

    <hr/>

     <div>
    
    {{if $datainfo['Company']['status'] == 2 }}
        <p class="alert alert-info">数据已提交审核，请操作。</p>
        <div class="row" style="text-align:center;width:500px;margin:0 auto;">
            <div class="col-md-6">
            
	            <form class="form" action="/admin/companies/passAudit/{{$datainfo['Company']['id']}}">
	            	<input type="hidden" name="data[Company][id]" value="{{$datainfo['Company']['id']}}">
	            	<input type="hidden" name="data[Company][status]" value="1">
	            	<button onclick="ajaxAction(this.form);window.location.reload();" class="btn btn-primary" >审核通过</button>
	        	</form>
            </div>
            <div class="col-md-6">
		        <form class="form" action="/admin/companies/edit/{{$datainfo['Company']['id']}}">
		            <button onclick="ajaxAction(this.form);window.location.reload();" class="btn btn-warning" >审核不通过</button>
		            <input type="hidden" name="data[Company][id]" value="{{$datainfo['Company']['id']}}">
		            <input type="hidden" name="data[Company][status]" value="3">
		            <textarea placeholder="请输入不通过的原因" required="required" class="form-control" style="margin-top:2px" row="2" col="80" name="data[Company][audit_msg]"></textarea>
		        </form>
            </div>
        </div>    
    {{/if}}
       </div>
   </div>
   <div role="tabpanel" class="tab-pane" id="CompanyMember">
   	<p><br></p>
   <table>
   	<thead><tr><th>编号</th><th>头像</th><th>姓名</th><th>手机</th><th>角色编号</th><th>角色名</th><th>操作</th></tr></thead>
   	<portlet cache="no" list_tpl="inner" portlet="body"  model="User" limit="1000" fields="User.*,CompanyMember.*,Role.id,Role.name" info="joins[0][table]=company_members&joins[0][alias]=CompanyMember&joins[0][type]=inner&joins[0][conditions][]=CompanyMember.user_id=User.id&joins[0][conditions][CompanyMember.company_id]=$id&joins[1][table]=roles&joins[1][alias]=Role&joins[1][type]=left&joins[1][conditions][]=CompanyMember.role_id=Role.id">
   		<tr><td>{{$item['id']}}</td><td>{{if $item['avatar']}}<img src="{{$item['avatar']}}" style="width:100px;height:100px;">{{/if}}</td><td>{{$item['username']}}</td><td>{{$item['mobile']}}</td><td>{{$item_all['CompanyMember']['role_id']}}</td><td>{{$item_all['Role']['name']}}</td><td><a href="/admin/company_members/edit/{{$item_all['CompanyMember']['id']}}">编辑</a>&nbsp;<a href="/admin/companies/delete_member/{{$item_all['CompanyMember']['company_id']}}/{{$item_all['CompanyMember']['user_id']}}">删除</a></td></tr>
   	</portlet>
   </table>
   </div>
   <div role="tabpanel" class="tab-pane" id="MoreInfo">   
   	<p><br></p> 
       <?php echo array_to_table($datainfo); ?>
   </div>
</div>